<?php

namespace app\common\model\order;

use app\common\enum\order\OrderAwardEnum;
use app\common\model\BaseModel;
use think\model\concern\SoftDelete;

/**
 * 订单奖励模型模型
 */
class OrderAward extends BaseModel
{
    use SoftDelete;
    protected $name = 'order_award';
    protected $autoWriteTimestamp = true;

    /**
     * 追加字段
     * @var string[]
     */
    protected $append = [
        'state_text',
        'award_type',       //奖励类型
    ];

    public function getStateTextAttr($value, $data)
    {
        $status = [
            0 => '未发放',
            1 => '已发放',
        ];
        return $status[$data['pay_status']];
    }

    public function getAwardTypeAttr($value, $data)
    {
        $types = OrderAwardEnum::getTypeName();
        return $types[$data['type']];
    }
}